import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import testpyqtdua

class main_win(QMainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self)

        #Main window settings
        self.setWindowTitle("MainApp Win")
        self.setMinimumSize(800 , 600)

        #Create the Menu Bar
        self.menu = self.menuBar()

        #Create the File menu entry in the bar
        self.file_menu = self.menu.addMenu('&File')

        #Create the File entry actions
        self.file_quit = self.file_menu.addAction('&Quit')
        self.file_quit.setShortcut(QKeySequence('Ctrl+Q'))
        #self.file_quit.setIcon(QIcon('img/icon.png'))
        self.connect(self.file_quit, SIGNAL("triggered()"), self.quit)

        #create the help meny entry in the Bar
        self.help_menu = self.menu.addMenu('&Help')

        #Create the help menu actions
        self.help_about = self.help_menu.addAction('About')
        #self.help_about.setIcon(QIcon('img/ico_about.png'))
        self.connect(self.help_about, SIGNAL("triggered()"), self.about)

        #TOOLBAR-------------------------------------------------------------------------
        self.toolbar = QToolBar(self)
        self.addToolBar(self.toolbar)

        #add menu actions to toolbar
        self.toolbar.addAction(self.file_quit)
        self.toolbar.addSeparator()
        self.toolbar.addAction(self.help_about)

        #main widget is a 2 tab one - for user and script application modes
        self.mainWidget = QTabWidget()
        self.setCentralWidget(self.mainWidget)
        self.tabuser = QWidget()
        self.u_layout = QVBoxLayout()
        self.tabuser.setLayout(self.u_layout)
        self.mainWidget.addTab(self.tabuser, 'User')

        #########################################################################################
        ##@brief Slot:About user action - pop application information dialog.
        #########################################################################################
    def about(self):
        #create the dialog
        #win = win_about(self)
        win = testpyqtdua.win_about(self)
        #show and execute as modal
        win.show()
        #to make sure it's gone, although the instance is local to the slot.
        del(win)

    #########################################################################################
    ##@brief Slot:Application exit, accessible through menu or toolbar icon.
    #########################################################################################
    def quit(self):
        #pop up goodBye dialog
        self.close()

def mymain():
    from PyQt4 import QtGui, QtCore
    app = QtGui.QApplication(sys.argv)
    app.setApplicationName('app')
    form = main_win()
    form.show()
    app.exec_()


if __name__ == "__main__":
    mymain()